/*
 * @Descripttion:
 * @version:
 * @Author: kl2018
 * @Date: 2019-12-04 15:14:43
 * @LastEditors: kl2018
 * @LastEditTime: 2020-08-10 14:16:31
 */
import React, { Component } from 'react';
import { WeaTop, WeaTab, WeaNewScroll, WeaLocaleProvider, WeaRightMenu } from 'ecCom';
import { Button } from 'antd';
import { observer, inject } from 'mobx-react';
import { WeaTableNew } from 'comsMobx';

const getLabel = WeaLocaleProvider.getLabel;
const WeaTable = WeaTableNew.WeaTable;

@inject('loginLogStore')
@observer
class AlterLog extends Component {
  componentDidMount() {
    const { getLogTableData, getTabData } = this.props.loginLogStore;
    getLogTableData();
    getTabData();
    // getSearchForm();
  }
  getTabButtonsAd() {
    let { loginLogStore } = this.props;
    const { getSearchData, showSearchDrop, searchForm } = loginLogStore;
    return [
      (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@clw0xk@search`} type="primary" onClick={() => getSearchData()}>{getLabel(388113, '搜索')}</Button>),
      (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@3s43ep@reset`} type="ghost" onClick={() => searchForm.resetForm()}>{getLabel(2022, '重置')}</Button>),
      (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@nbmqsj@cancel`} type="ghost" onClick={() => showSearchDrop()}>{getLabel(31129, '取消')}</Button>),
    ];
  }

  getSearchForm() {
    const { searchForm } = this.props.loginLogStore;
    return (
      <WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@rn9l64`} ref="scroll">
        {searchForm.render({ needTigger: true })}
      </WeaNewScroll>
    );
  }

  getRightMenu() {
    const { loginLogStore } = this.props;
    const { logTableStore } = loginLogStore;
    const rightMenuDatas = [{
      key: '1',
      disabled: false,
      icon: <i className="icon-coms-Add-to" />,
      content: getLabel('387597', '导出EXCLE'),
      onClick: () => logTableStore.exportCurrent(),
    }];
    return rightMenuDatas;
  }

  render() {
    let loginLogStore = this.props.loginLogStore;
    let { topTab, selectedKey, changeDate, logTableStore } = loginLogStore;
    return (
      <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@y98ie6`} datas={this.getRightMenu()}>
        <div className="alterLogtop">
          <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@ibgbp8`}
            title={<span style={{ color: '#333333' }}>{getLabel(2059, '登录日志')}</span>}
            icon={<i className="icon-coms-rizhizhongxin" />}
            iconBgcolor="#0079DE"
            buttons={[<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@u5e6an@export`} type="primary" onClick={() => logTableStore.exportCurrent()} >{getLabel(387597, '导出EXCLE')}</Button>]}
          >
            <WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@3pjkv6`}
              datas={topTab}
              selectedKey={selectedKey}
              searchType={['base']}
              // showSearchAd={showSearchAd}
              // setShowSearchAd={bool=>{showSearchDrop(bool)}}
              // buttonsAd={this.getTabButtonsAd()}
              // searchsAd={this.getSearchForm()}
              onSearch={text => loginLogStore.getSearchData(text)}
              keyParam="viewcondition" // 主键
              onChange={(v) => { changeDate(v); }}
              advanceHeight={80}
            />
            <WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@qc0zgr`} comsWeaTableStore={logTableStore} needScroll={true} />
          </WeaTop>
        </div>
      </WeaRightMenu>

    );
  }
}
export default AlterLog;
